package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.ActivitiesDetailBean;
import com.topscore.uke.mvp.contractors.GetActivitiesNewsDetailContractor;
import com.topscore.uke.mvp.model.GetActivitiesNewsDetailModel;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.utils.UserInfoManager;

public class GetActivitiesNewsDetailPresenter implements GetActivitiesNewsDetailContractor, GetActivitiesNewsDetailContractor.Presenter {
    private View mView;
    private Model mModel;

    public GetActivitiesNewsDetailPresenter(View view) {
        this.mView = view;
        this.mModel = new GetActivitiesNewsDetailModel(new Model.CallBack() {
            @Override
            public void onSuccess(BaseResponse<ActivitiesDetailBean> response) {
                mView.onGetDataSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode, errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void getNewsData(String titleCode) {
        mView.onLoading("");
        mModel.getData(UserInfoManager.getUserInfo().getLoginName(),
                titleCode);
    }
}
